//--------------------------------------------------------------------------------------
// register the function
 var newRegistery1 = new Array("getPlayerList", "cretatePlayerListTable" ); 
 allJsonsRegistry = allJsonsRegistry.concat(newRegistery1);


//--------------------------------------------------------------------------------------

function cretatePlayerListTable(playerListTableInfoDictionary) 
{
    var mySection = document.getElementById('id_playerList');
    if( playerListTableInfoDictionary.playersList.length == 0 )
    {
        mySection.innerHTML = '';
    }
    else
    {   
        var str ='<div class="section">';
        str += '    <h2>Launch the bet room</h2>';
        str += '    <div class="oneLine" style="color:Red;">You need to notify the people you want in that they need to join this bet room.';
        str += '         They will need the password \'' + playerListTableInfoDictionary.betroomPwd + '\'.';
        str += '         Once they have joined, they will appear in the list below.</div>';
        str += '    <div class="myLeft2" style="display:table;">';
        str += '    <div class="oneLine"> Carefully un-tick the un-wanted players and launch the bet room. Each selected player will start with an initial MtM of 10000 Chochoros.</div>';
        str += '        <form action="/createBetroom/launchBetroom/" method="post" align="left">';
        str += '        <input type="hidden" value="'+getCookie('csrftoken')+'" name="csrfmiddlewaretoken">';
        str += '            <table id="id_inputPlayerListTable" ></table>';
        str += '            <input class="myRoundCorners" type="submit" value="Launch bet room!"/>';
        str += '        </form>';
        str += '    </div>';
        str += '</div>';
        mySection.innerHTML = str;
        var myTable = document.getElementById('id_inputPlayerListTable');
        // add the header
        var headerRow = myTable.insertRow(0);
        var newCell = headerRow.insertCell(0);
        newCell.innerHTML = '<th ><div class="myBold">Player</div></th>';
        newCell = headerRow.insertCell(1);
        newCell.innerHTML = '<th ><div class="myBold">Untick if not wanted</div></th>';
        for (var i = 0; i < playerListTableInfoDictionary.playersList.length; i++)
        {
              var newRow = myTable.insertRow(i+1);
              var newCell = newRow.insertCell(0);
              var name0 = playerListTableInfoDictionary.playersList[i].name;
              newCell.innerHTML = name0;
              newCell = newRow.insertCell(1);
              var string0 = '<td> <input type="checkbox" name=\"'+name0+'\" id="id_check_std" name="check_std"  CHECKED >In</input></td>';
              newCell.innerHTML = string0;
        }
        attachCSS3Properties();
    }
    return false;
};


//--------------------------------------------------------------------------------------

function deleteBetroom(betroomName) 
{
    var test = confirm('Are you realy sure? All the data will be lost. Do you want to continue?');
    if( test )
    {
        // save the base and calls the actual function
        var args = { 
           type: "POST", 
           url: "/createBetroom/deleteBetroom/",
           data: { 'betroom':betroomName }, 
           cache: false,
           complete:function(result)  {document.location.href = '/betrooms/'; },
           error: function(errorThrown)  { document.write(errorThrown.responseText);  }
        };
        $.ajax(args);
    }
    return false;
 };